<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<div class="modal-dialog ms-modal-dialog">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
              class="sr-only">Close</span></button>
      <h4 class="modal-title">标记已支付</h4>
    </div>

    <form class="form-horizontal ms-form" role="form" method="POST" action="${ctx.host}/orders/${id}/pay"
          data-validate="true">

      <input type="hidden" name="_method" value="PATCH"/>
      <input type="hidden" name="id" value="${id}"/>

      <div class="modal-body">

        <!-- <p class="confirm">
           <i class="glyphicon glyphicon-flash glyphicon-position-fix-2"></i>&nbsp;&nbsp;是否确认标记已支付？
         </p>-->
        <div class="form-group ms-form-group">
          <label class="col-xs-3 control-label"><span class="text-red">*</span>支付方式：</label>
          <div class="col-xs-8">
            <select name="orderPayType" class="select2 form-control" tabindex="3">
              <option></option>
              <c:forEach var="orderPayType" items="${enums['OrderPayType']}">
                <option value="${orderPayType}" ${orderPayType == order.orderPayType ? 'selected' : ''}>${orderPayType.description}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-3"><span class="text-red">*</span>支付流水号：</label>
          <div class="col-xs-8">
            <input type="text" class="form-control" name="payCode" value="" data-validate="required" tabindex="5"
                   placeholder="请输入支付流水号" autocomplete="off"/>
          </div>
        </div>

        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-3"><span class="text-red">*</span>支付时间：</label>
          <div class="col-xs-8">
            <input type="datetime" name="payTime" class="form-control datetime" placeholder="请选择支付时间"
                   autocomplete="off"/>
          </div>
        </div>

        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-3"><span class="text-red">*</span>支付金额(RMB)：</label>
          <div class="col-xs-8">
            <input type="text" class="form-control" name="actualPayPrice" value="" data-validate="required" tabindex="5"
                   placeholder="请输入支付金额" autocomplete="off"/>
          </div>
        </div>

        <div class="form-group  ms-form-group" style="min-height: 100px;">
          <label class="control-label col-xs-3">
            <c:if test="${!currentPrincipal.isFinanceUser()}">
              <span class="text-red">*</span>
            </c:if>上传凭证：
          </label>
          <div class="col-xs-8 upload-cover">
            <button type="button" id="pickCover" class="edit-btn" style="position: relative">
              <span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>&nbsp;&nbsp;选择文件
            </button>
            <div id="coverPreviewList" style="position: absolute;top: 0;width: 100px; height: 100px;">
              <img id="coverPreview" src=""  style="display: block; width: 100%;"/>
            </div>
            <input type="hidden" id="cover" name="payPic" value=""  ${!currentPrincipal.isFinanceUser() ? 'data-validate="required"' : ""}/>
            <label id="messageCover" class="control-label messageCover hide"></label>
          </div>
        </div>

      </div>

      <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
      </div>
    </form>

  </div>
</div>
<script>
  $('select').select2({
    placeholder: '请选择',
    minimumResultsForSearch: -1,
    allowClear: true,
  });
  $(document).ready(function () {
    var now = new Date();
    now.setSeconds(0);
    $('.datetime').datetimepicker({
      format: 'yyyy-mm-dd hh:ii:ss',
      autoclose: true,
      language: 'zh-CN',
      todayBtn: 'linked',
      todayHighlight: true,
      pickerPosition: 'bottom-right',
      minView: 'hour',
      initialDate: now,
    });
  })
  $(document).on("click", "#coverPreviewList", function() {
    $("#pickCover").trigger("click")
  })
</script>